public class Computer {
    private double price;
    private String brand;
    private static Computer instance;

    // 私有构造函数，防止外部实例化
    private Computer(double price, String brand) {
        this.price = price;
        this.brand = brand;
    }

    // 提供全局访问点获取实例
    public static synchronized Computer getInstance() {
        if (instance == null) {
            instance = new Computer(0.0, "DefaultBrand");
        }
        return instance;
    }

    // 初始化方法
    public void init(double price, String brand) {
        this.price = price;
        this.brand = brand;
    }

    @Override
    public String toString() {
        return "Computer{" +
                "price=" + price +
                ", brand='" + brand + '\'' +
                '}';
    }

    // 禁止拷贝构造函数
    private Computer(Computer rhs) {
        throw new UnsupportedOperationException("Copy constructor is not supported");
    }
}

